package com.wifi.eshipewifi;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.wifi.BaseApplication;
import com.wifi.imp.MessageListener;

public class AboutActivity extends AppCompatActivity implements View.OnClickListener,MessageListener{
    ImageButton ib_back;
    TextView tv_include_tittle;
    TextView tv_mac;
    TextView tv_imei;
    TextView tv_gujian;
    TextView tv_ruanjian;
    TextView tv_app;
    BaseApplication application;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        application = (BaseApplication) getApplication();

        tv_include_tittle = (TextView) findViewById(R.id.tv_include_tittle);
        tv_mac = (TextView) findViewById(R.id.tv_mac);
        tv_imei = (TextView) findViewById(R.id.tv_imei);
        tv_gujian = (TextView) findViewById(R.id.tv_gujian);
        tv_ruanjian = (TextView) findViewById(R.id.tv_ruanjian);
        tv_app = (TextView) findViewById(R.id.tv_app);
        ib_back = (ImageButton) findViewById(R.id.ib_back);
        tv_include_tittle.setText("关于");
        ib_back.setOnClickListener(this);
    }

    @Override
    protected void onResume() {//每个activity都要加这一句
        super.onResume();
        if(application==null)
            application = (BaseApplication) getApplication();
        application.setMsgListener(this);
        application.sendMsg("$about;");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ib_back:
                this.finish();
                break;
        }
    }

    String TAG="AboutActivity";
    @Override
    public void MessageGetListener(String msg) {
        if (msg.trim().length() > 0) {
            Log.i(TAG, "mhandler接收到obj=" + msg);
            String[] s1=msg.split(";");
            if(s1[0].indexOf("about")!=-1){//about数据
//                $about;00:0c:43:76:20:77,867377020132027,Linux PandoraBox 3.14.44,appServer_v1.0,app_v1.0;\r\n
                String[] about = s1[1].split(",");
                tv_mac.setText(about[0]);
                tv_imei.setText(about[1]);
                tv_gujian.setText(about[2]);
                tv_ruanjian.setText(about[3]);
                tv_app.setText(about[4]);
            }
        }
    }
}
